﻿<local:BaseLab x:Class="Rxx.Labs.Reactive.UI.ObservableSyndicationLab"
							 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
							 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
							 xmlns:local="clr-namespace:Rxx.Labs"
							 xmlns:labs="clr-namespace:DaveSexton.Labs;assembly=DaveSexton.Labs"
							 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
							 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
							 xmlns:cm="clr-namespace:System.ComponentModel;assembly=System.Windows"
							 xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
							 mc:Ignorable="d" 
							 d:DesignHeight="300" d:DesignWidth="300"
							 DataContext="{Binding RelativeSource={RelativeSource Self}}">

	<local:BaseLab.Resources>
		<CollectionViewSource x:Key="Feed" Source="{Binding Feed}">
			<CollectionViewSource.SortDescriptions>
				<cm:SortDescription PropertyName="Value.LastUpdatedTime" Direction="Descending" />
			</CollectionViewSource.SortDescriptions>
		</CollectionViewSource>
	</local:BaseLab.Resources>

	<labs:OutOfBrowserContentControl>

		<toolkit:DockPanel>

			<StackPanel toolkit:DockPanel.Dock="Top">
				<StackPanel.Resources>
					<Style x:Key="Panel" TargetType="FrameworkElement">
						<Setter Property="Margin" Value="5" />
					</Style>
					<Style TargetType="StackPanel" BasedOn="{StaticResource Panel}" />
					<Style TargetType="Grid" BasedOn="{StaticResource Panel}" />
					<Style TargetType="RadioButton">
						<Setter Property="Margin" Value="8" />
					</Style>
					<Style TargetType="Button">
						<Setter Property="Padding" Value="4" />
					</Style>
					<Style TargetType="TextBox">
						<Setter Property="VerticalAlignment" Value="Center" />
					</Style>
				</StackPanel.Resources>

				<toolkit:DockPanel>
					<TextBlock toolkit:DockPanel.Dock="Left" VerticalAlignment="Center" Text="Feed: " />
					<TextBox Name="FeedTextBox" Text="{Binding FeedUrl, Mode=TwoWay, ValidatesOnExceptions=True}" />
				</toolkit:DockPanel>

				<StackPanel Orientation="Horizontal">
					<RadioButton GroupName="Format" Content="RSS 2.0" IsChecked="{Binding IsFormatRss, Mode=TwoWay}" />
					<RadioButton GroupName="Format" Content="Atom 1.0" IsChecked="True" />
				</StackPanel>

				<toolkit:DockPanel>
					<TextBlock toolkit:DockPanel.Dock="Left" VerticalAlignment="Center" Text="Auto refresh (hh:mm:ss:): " />
					<TextBox Name="AutoDownloadIntervalTextBox" Text="{Binding AutoRefreshInterval, Mode=TwoWay, ValidatesOnExceptions=True}" />
				</toolkit:DockPanel>

				<Grid>
					<Button Name="ApplySettingsButton" Content="Apply Settings"
									VerticalAlignment="Center" HorizontalAlignment="Center"
									Click="ApplySettingsButton_Click" />
				</Grid>

				<StackPanel Orientation="Horizontal">
					<TextBlock Text="{Binding Count, Source={StaticResource Feed}}" />
					<TextBlock Text=" Item(s)" />
				</StackPanel>
			</StackPanel>

			<ListBox ItemsSource="{Binding Source={StaticResource Feed}}">

				<ListBox.ItemContainerStyle>
					<Style TargetType="ListBoxItem">
						<Setter Property="Padding" Value="8" />
					</Style>
				</ListBox.ItemContainerStyle>

				<ListBox.ItemTemplate>
					<DataTemplate>

						<StackPanel>
							<TextBlock Text="{Binding Value.LastUpdatedTime}" />
							<TextBlock Text="{Binding Value.Title.Text}" FontWeight="Bold" />
							<TextBlock Text="{Binding Value.Links[0].Uri}" />
							<TextBlock Text="{Binding Value.Content.Text}" MaxHeight="50" />
						</StackPanel>

					</DataTemplate>
				</ListBox.ItemTemplate>

			</ListBox>

		</toolkit:DockPanel>

	</labs:OutOfBrowserContentControl>

</local:BaseLab>